/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2025. All rights reserved.
 * Description: Hmfs-tools quota
 */

#ifndef HMFS_QUOTA_H
#define HMFS_QUOTA_H

#include <memory>

namespace OHOS {
namespace Hmfs {
constexpr uint32_t QUOTA_DATA_BLOCK_COUNT = 2;
constexpr uint32_t MAX_IQ_TIME = 604800; // one week in seconds (7*24*60*60)
constexpr uint32_t MAX_DQ_TIME = 604800; // one week in seconds (7*24*60*60)
constexpr uint32_t QT_TREE_OFFSET = 1;
constexpr uint32_t DEFAULT_PROJECT_ID = 0;
constexpr uint32_t QT_DEFAULT_FREE_ENTRIES = 5;
constexpr uint32_t QUOTA_CONTENT_ONE_OFFSET = 1024;
constexpr uint32_t QUOTA_CONTENT_ONE_VALUE = 2;
constexpr uint32_t QUOTA_CONTENT_TWO_OFFSET = 2048;
constexpr uint32_t QUOTA_CONTENT_TWO_VALUE = 3;
constexpr uint32_t QUOTA_CONTENT_THREE_OFFSET = 3072;
constexpr uint32_t QUOTA_CONTENT_THREE_VALUE = 4;
constexpr uint32_t QUOTA_CONTENT_FOUR_OFFSET = 4096;
constexpr uint32_t QUOTA_CONTENT_FOUR_VALUE = 5;
constexpr uint32_t QUOTA_CONTENT_FIVE_OFFSET = 5128;
constexpr uint32_t QUOTA_CONTENT_FIVE_VALUE = 1;

constexpr std::array<uint32_t, 3> INIT_QUOTA_MAGICS = {
    0xd9c01f11, /* USR_QUOTA */
    0xd9c01927, /* GRP_QUOTA */
    0xd9c03f14  /* PROJECT_QUOTA */
};

enum QuotaType {
    USR_QUOTA = 0,
    GRP_QUOTA = 1,
    PROJECT_QUOTA = 2,
    MAX_QUOTAS = 3,
};

struct DiskQuotaHeader {
    uint32_t dqhMagic;
    uint32_t dqhVersion;
};

struct DiskQuotaInfo {
    uint32_t dqiBgrace;
    uint32_t dqiIgrace;
    uint32_t dqiFlags;
    uint32_t dqiBlocks;
    uint32_t dqiFreeBlk;
    uint32_t dqiFreeEntry;
};

struct DiskQuotaBlock {
    uint32_t dqbId;
    uint32_t dqbPad;
    uint64_t dqbIhardlimit;
    uint64_t dqbIsoftlimit;
    uint64_t dqbCurinodes;
    uint64_t dqbBhardlimit;
    uint64_t dqbBsoftlimit;
    uint64_t dqbCurspace;
    uint64_t dqbBtime;
    uint64_t dqbItime;
};
} // namespace Hmfs
} // namespace OHOS
#endif // HMFS_QUOTA_H